 ;(function(){
    window.onload = function(){
        subLiChs();
        slideImg();
    };
    //分支导航的点击样式变化
    function subLiChs(){
        var subLists = document.getElementsByClassName("sub-nav")[0].getElementsByTagName("li");
        for(var i=0,l=subLists.length;i<l;i++){
            subLists[i].onclick = function(){
                for(var k=0;k<l;k++){
                    subLists[k].className = "";
                }
                this.className = "active";
            };
        }
    }

    //滑动图片
    function slideImg(){
        var swiperImgs = document.getElementsByClassName("main-con")[0].getElementsByTagName("img");
        for(var k1=0,j1=swiperImgs.length;k1<j1;k1++){
            swiperImgs[k1].index = k1;
            swiperImgs[k1].onclick = function(){
                document.getElementsByClassName("swiper-container")[0].style.display = "block";
                var mySwiper = new Swiper(".gallery-top",{
                    loop:true,
                    pagination:".swiper-pagination",
                    initialSlide : this.index,
                    paginationClickable:true,
                    onInit:function(swiper){
                        swiper.container[0].addEventListener("click",function(e){
                            e.stopPropagation();
                            document.getElementsByClassName("swiper-container")[0].style.display = "none";
                        });
                        var swiperImgsBig = swiper.container[0].getElementsByTagName("img");
                        swiper.container[0].style.height = window.innerHeight - 50 + "px";
                        swiper.container[0].style.backgroundColor = "rgba(0,0,0,.6)";
                        for(var i=0,l=swiperImgsBig.length;i<l;i++){
                            swiperImgsBig[i].style.display = "block";
                            swiperImgsBig[i].style.position = "absolute";
                            swiperImgsBig[i].onclick = function(e){e.stopPropagation();};
                            swiperImgsBig[i].style.top = window.innerHeight/2 - swiperImgsBig[i].offsetHeight/2 - 25 + "px";
                        }
                    }
                });
            };
        }
        document.getElementById("swiper-close").onclick = function(){
            document.getElementsByClassName("swiper-container")[0].style.display = "none";
        };
    }
 })();
 